import urllib.request

response = urllib.request.urlopen('http://www.baidu.com')
html = response.read()
print(html)

# bytes format
fout = open('huhx.txt', 'wb')
fout.write(html)
fout.close()

fout = open('huhx.html', 'wb')
fout.write(html)
fout.close()
